package com.syni.mdd.yhd.common.all.controller.api;

import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckParams;
import com.syni.mdd.yhd.common.all.constants.ResultCode;
import com.syni.mdd.yhd.common.all.constants.ResultMsg;
import com.syni.mdd.yhd.common.all.entity.BmsBusinessCoupon;
import com.syni.mdd.yhd.common.all.service.BmsDxGroupBuyService;
import com.syni.mdd.yhd.common.all.service.api.AuroraPushService;
import com.syni.mdd.yhd.common.all.service.market.BmsMarketReceService;
import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @className ApiAuroraPushController
 * @description TOO
 * @Author cfx
 * @DATE 2019/7/17 9:06
 * @VERSION 1.0
 **/
@RestController
@RequestMapping("/apiUserCoupon")
public class ApiBmsUserCouponController {
    @Autowired
    AuroraPushService auroraPushService;

    @Autowired
    BmsDxGroupBuyService bmsDxGroupBuyService;

    @Autowired
    BmsMarketReceService bmsMarketReceService;

    @PostMapping("/handleMarketUserCoupon")
    @CheckParams(params = {"openId"})
    public Map<String,Object> handleMarketUserCoupon(@RequestBody ParamsMap paramsMap){
        String openId = paramsMap.getString("openId");
        Map<Integer, BmsBusinessCoupon> ret = bmsMarketReceService.handleReceCoupon(openId);
        if(ret.size() > 0){
            return ResultMapHelper.success(ret);
        }
        return ResultMapHelper.result(ResultCode.CODE_ERROR_100, ResultMsg.MSG_GET_FAIL);
    }



}
